package u17.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import u17.model.TreeNode;


@Controller
@RequestMapping("menu")
public class MenuController {
	private static final Logger logger = Logger.getLogger(MenuController.class);
	
	@ResponseBody
	@RequestMapping("/tree")
	public List<TreeNode> getUserData(HttpServletRequest request){
		List<TreeNode> re = new ArrayList<TreeNode>();
		
		logger.debug("执行了。。。。start");
		Map<String,Object> map = new HashMap<String, Object>();
		
		List<TreeNode> list = new ArrayList<TreeNode>();// 子节点
		
		TreeNode tn1 = new TreeNode();
		tn1.setId(new Integer(2));
		tn1.setText("玩家信息");
		map.put("url", request.getContextPath()+"/user/getAllUser.do");
		tn1.setAttributes(map);
		list.add(tn1);
		
		    
		TreeNode tn = new TreeNode();
		tn.setId(new Integer(1));
		tn.setText("菜单");
		tn.setChildren(list);
		
		TreeNode tn2 = new TreeNode();
		tn2.setId(new Integer(1));
		tn2.setText("第二");
		
		re.add(tn);
		re.add(tn2);
		
		logger.debug("执行了。。。。end");
		return re;
	}
}
